; ****************************************************
; **                                                **
; ** 10/24/09 - This is a Solitaire Script file.    **
; **            Designed by Peter Wiseman for :     **
; **                                                **
; **                -- IPHONE VERSION --            **
; **                                                **
; **    Solitaire City Classic v1.00 - KLONDIKE     **
; **                                                **
; ****************************************************


; *******************************************
; **********  G A M E   R U L E S  **********
; *******************************************

DEFINE HELPMSGS

STANDARDDECK:BOX("FD","FD"),ARROW("FD"-20,"FD"+60)TO("FD"+5,"FD"+15),SKIP,BELOW:The game is played with a single, standard deck of 52 playing cards. The cards are shuffled and placed face down to form the "Stock".
TABLEAU:BOX("T1","T7"),ARROW("T4"-100,"T7"+120)TO("T4"-135,"T7"),SKIP,RIGHT:28 cards are then dealt from the stock to 7 columns of increasing size, to form the "Tableau".
OBJECTIVE:BOX("F1","F4"),ARROW("F2","F2"+69)TO("F2"-40,"F2"),SKIP,BELOW:The object of Klondike is to build each of the 4 "Foundations" up in ascending sequence from Ace,2,3,4 to King, all the same suit, until they each contain 13 cards.
DECKDEAL::Touch the stock to deal a card to a "Waste Pile", where the top uncovered card is always available for play.
DECKDEAL::When no more valid moves are available, touch the stock to deal another card to the waste pile.
GATHERDECK::When the stock has expired, touch the re-use icon to turn over the waste pile to reform the stock.
STARTFOUNDS::As each Ace becomes available, transfer it to the row above the tableau to start a new foundation.
STARTFOUNDS::You can quickly tap on a card to send it flying to the foundations.
BUILDFOUNDS::Foundations may be built on by cards of the same suit if they follow the ascending sequence:~A,2,3,4,5,6,7,8,9,10,J,Q,K.
TURN_OVER::Touch an exposed, face down, tableau card to turn it over.
SINGLEKINGGAP::Gaps in the tableau may be filled by Kings.
SINGLEALTCOLDES::Transfer cards to the tableau in a descending sequence of alternating colours.~(eg red 6, black 5, red 4 etc).
COLUMNKINGGAP::Gaps in the tableau may be filled by a whole column, headed by a King.
COLUMNALTCOLDES::A full column of face up tableau cards may be built on another column if the join follows the descending sequence, alternating colours rule.
TABTOTAB::Single, uncovered, face up cards may be moved to another tableau column if it makes a descending sequence of alternating colours.~(eg black 10, red 9, black 8 etc) 
PARTIALSINGLE::You can build a single, uncovered face up card on another column. Sometimes this will release a card that can be played to the foundations.
PARTIALCOLS::You can build a partial column of packed cards on another column. Sometimes this will release a card that can be played to the foundations.

DEFINE GAMERULES

UPLOAD=1,Rule 1 - Deal 1, Unlimited Passes
UPLOAD=2,Rule 2 - Deal 3, Unlimited Passes
UPLOAD=3,Rule 3 - Deal 1, Three Passes
UPLOAD=4,Rule 4 - Deal 1, No Re-deals
UPLOAD=5,Rule 5 - Deal 1, Vegas Rules
UPLOAD=6,Rule 6 - Deal 3, Vegas Rules


; ***************************************************
; **********  C A R D   P O S I T I O N S  **********
; ***************************************************


; This is the size of the play area that holds the cards
; and always fits inside the current window size.

DEFINE TABLE (0,0,0,0)
; 35% of a card height below the bottom of the screen
DEFINE STACKLOWERLIMIT (240,240,35%) 

DEFINE SCORE (68,-102) S(0,0,32)
[5,6]DOLLARS
[5,6]INITIAL -52
[5,6]REDUCE 0
[5,6]NOGRANNYMODE
DEFINE TIME (-67,-102) S(0,0,32)
DEFINE BONUS
ENDING Klondike 50,160

; The deck is a special case as, in general, we can only take cards from
; it and shouldn't be able to build on it.

DEFINE DECK (132,-143,AboveScore) L(-129,-143) S(0,0,19)
SHOWNUMBER

; The following CENTRE is the centre of the face up pile

[!IPAD,2,6]CENTRE (52,-149,AboveScore) L(-78,-149) S(0,0,25)
[IPAD,2,6]CENTRE (62,-145,AboveScore) L(-78,-145) S(0,0,18)
[1,3,4,5]CENTRE (80,-143,AboveScore) L(-75,-143) S(0,0,19)
[2,6]STACK CARDS Deck
[1,3,4,5]STACK CARDS On Top
RULES "FU"


; Let's define The Tableau


DEFINE STACK "T1"

OUTLINE
CENTRE (-132,-63,UnderScore) S(0,0,40)
STACK CARDS Down2
RULES "Tableau"


DEFINE STACK "T2"

OUTLINE
CENTRE (-88,-63,UnderScore) S(0,0,40)
STACK CARDS Down2
RULES "Tableau"


DEFINE STACK "T3"

OUTLINE
CENTRE (-44,-63,UnderScore) S(0,0,40)
STACK CARDS Down2
RULES "Tableau"


DEFINE STACK "T4"

OUTLINE
CENTRE (0,-63,UnderScore) S(0,0,40)
STACK CARDS Down2
RULES "Tableau"


DEFINE STACK "T5"

OUTLINE
CENTRE (44,-63,UnderScore) S(0,0,40)
STACK CARDS Down2
RULES "Tableau"


DEFINE STACK "T6"

OUTLINE
CENTRE (88,-63,UnderScore) S(0,0,40)
STACK CARDS Down2
RULES "Tableau"


DEFINE STACK "T7"

OUTLINE
CENTRE (132,-63,UnderScore) S(0,0,40)
STACK CARDS Down2
RULES "Tableau"


; The Foundations are next


DEFINE STACK "F1"

OUTLINE
CENTRE (-132,-143,AboveScore) L(0,-143) S(0,0,21)
STACK CARDS On Top
RULES "Foundations"


DEFINE STACK "F2"

OUTLINE
CENTRE (-88,-143,AboveScore) L(44,-143) S(0,0,21)
STACK CARDS On Top
RULES "Foundations"


DEFINE STACK "F3"

OUTLINE
CENTRE (-44,-143,AboveScore) L(88,-143) S(0,0,21)
STACK CARDS On Top
RULES "Foundations"


DEFINE STACK "F4"

OUTLINE
CENTRE (0,-143,AboveScore) L(132,-143) S(0,0,21)
STACK CARDS On Top
RULES "Foundations"



; ***************************************************
; **********  G A M E   O B J E C T I V E  **********
; ***************************************************

; This is how the game is won


DEFINE OBJECTIVE

; the following number of cards are required in each stack, to win

"F1" = 13
"F2" = 13
"F3" = 13
"F4" = 13


; This is how we can get the computer to help us out

DEFINE AUTOFINISH

"FD" < 1
"FU" < 2
"T1" = No Face Down Cards
"T2" = No Face Down Cards
"T3" = No Face Down Cards
"T4" = No Face Down Cards
"T5" = No Face Down Cards
"T6" = No Face Down Cards
"T7" = No Face Down Cards


; *******************************************
; **********  G A M E   R U L E S  **********
; *******************************************


DEFINE RULES "FD"

REVEAL

PICK UP

UnCovered Face Down

TURN OVER

PUT DOWN


;--------------------------------------------


DEFINE RULES "FU"

REVEAL

PICK UP

UnCovered Face Up
Lone Face Up
Lone Face Up On Empty

TURN OVER

PUT DOWN

;--------------------------------------------


DEFINE RULES "Foundations"

REVEAL

PICK UP

Uncovered Face Up
Lone Face Up
Lone Face Up On Empty

REVEAL

TURN OVER

PUT DOWN

FROM "FU","T1","T2","T3","T4","T5","T6","T7"
TYPE Uncovered Face Up,Lone Face Up,Lone Face Up On Empty

TO Empty
Any Ace
[1,2,3,4]SCORE 60
[5,6]SCORE 5
SOUND "DragFound"
CONSTRUCTIVE 10
[1,2,3,4]DOUBLECLICK 60
[5,6]DOUBLECLICK 5
SOUND "ClickFound"
HELP "StartFounds"
EFFECT

TO Uncovered Face Up,Lone Face Up,Lone Face Up On Empty
Ascending Value
Same Suit
[1,2,3,4]SCORE 60
[5,6]SCORE 5
SOUND "DragFound"
CONSTRUCTIVE 10
[1,2,3,4]DOUBLECLICK 60
[5,6]DOUBLECLICK 5
SOUND "ClickFound"
HELP "BuildFounds"
EFFECT

FROM "F1","F2","F3","F4"
TO Empty
Any Ace
SOUND "MoveCard"

;--------------------------------------------


DEFINE RULES "Tableau"

REVEAL

PICK UP

Uncovered Face Up
Lone Face Up
Lone Face Up On Empty
Full Face Up Column
Full Face Up Column On Empty
Descending Alternating Sequences


TURN OVER

Uncovered Face Down
[1,2,3,4]SCORE 25
CONSTRUCTIVE 9
SOUND "TurnOver"
HELP "Turn_Over"


PUT DOWN

FROM "FU"
TYPE Uncovered Face Up,Lone Face Up,Lone Face Up On Empty

TO Empty
Any King
[1,2,3,4]SCORE 45
SOUND "FillSpace"
CONSTRUCTIVE 5
HELP "SingleKingGap"

TO Uncovered Face Up,Lone Face Up,Lone Face Up On Empty
Descending Value
Alternating Colours
[1,2,3,4]SCORE 45
SOUND "BuildSingle"
CONSTRUCTIVE 5
HELP "SingleAltColDes"

FROM "T1","T2","T3","T4","T5","T6","T7"
TYPE Lone Face Up On Empty
TO Empty
Any King
SOUND "MoveCard"

TYPE Lone Face Up

TO Empty
Any King
SOUND "FillSpace"
CONSTRUCTIVE 8
HELP "SingleKingGap"

TYPE Lone Face Up,Lone Face Up On Empty

TO Uncovered Face Up,Lone Face Up,Lone Face Up On Empty
Descending Value
Alternating Colours
SOUND "BuildSingle"
CONSTRUCTIVE 8
HELP "TabToTab"

TYPE Full Face Up Column

TO Empty
Any King
SOUND "FillSpace"
CONSTRUCTIVE 8
HELP "ColumnKingGap"

TO Uncovered Face Up,Lone Face Up,Lone Face Up On Empty
Descending Value
Alternating Colours
SOUND "BuildCol"
CONSTRUCTIVE 8
HELP "ColumnAltColDes"

TYPE Full Face Up Column On Empty

TO Empty
SOUND "MoveCard"
Any King

TO Uncovered Face Up,Lone Face Up,Lone Face Up On Empty
Descending Value
Alternating Colours
SOUND "BuildCol"
CONSTRUCTIVE 8
HELP "ColumnAltColDes"

TYPE Uncovered Face Up

TO Uncovered Face Up,Lone Face Up,Lone Face Up On Empty
Descending Value
Alternating Colours
SOUND "BuildSingle"
REVEAL
HELP "PartialSingle"

TYPE Partial Face Up Column
TO Uncovered Face Up,Lone Face Up,Lone Face Up On Empty
Descending Value
Alternating Colours
SOUND "BuildPart"
REVEAL
HELP "PartialCols"

FROM "F1","F2","F3","F4"
TYPE Uncovered Face Up,Lone Face Up,Lone Face Up On Empty

TO Empty
Any King
[1,2,3,4]SCORE -75
[5,6]SCORE -5
SOUND "BadMove"

TO Uncovered Face Up,Lone Face Up,Lone Face Up On Empty
Descending Value
Alternating Colours
[1,2,3,4]SCORE -75
[5,6]SCORE -5
SOUND "BadMove"

; *******************************************
; **********  D E A L   C A R D S  **********
; *******************************************

; Let's define how the cards should be dealt when we start a new game :

DEFINE DEAL
[1,2,3,4]UNDO -25
[5,6]NOUNDOS
[2,6]CARDSTODEAL 3
[1,3,4,5]CARDSTODEAL 1
[1,2]PASSES Unlimited
[3,6]PASSES 3
[4,5]PASSES 1
[2,4]REDEALPOINTS -125 After 3
[3]REDEALPOINTS -200 After 1
[1]REDEALPOINTS -175 After 0
[5,6]REDEALPOINTS 0 After 1

[2,6]DEALSPEED 100,230
[1,3,4,5]DEALSPEED 100,75

OUTLINE "F1"
OUTLINE "F2"
OUTLINE "F3"
OUTLINE "F4"

FLIPSCREEN

SHUFFLE
HELP "StandardDeck"
SOUNDONSILENCE "Shuffle2"

; Set the deal speed and pause time in 1/1000 sec

SET DEALSPEED3D 100,25

DEAL&PAUSE Face Up to "T1"
DEAL&PAUSE Face Down to "T2"
DEAL&PAUSE Face Down to "T3"
DEAL&PAUSE Face Down to "T4"
DEAL&PAUSE Face Down to "T5"
DEAL&PAUSE Face Down to "T6"
DEAL&PAUSE Face Down to "T7"

DEAL&PAUSE Face Up to "T2"
DEAL&PAUSE Face Down to "T3"
DEAL&PAUSE Face Down to "T4"
DEAL&PAUSE Face Down to "T5"
DEAL&PAUSE Face Down to "T6"
DEAL&PAUSE Face Down to "T7"

DEAL&PAUSE Face Up to "T3"
DEAL&PAUSE Face Down to "T4"
DEAL&PAUSE Face Down to "T5"
DEAL&PAUSE Face Down to "T6"
DEAL&PAUSE Face Down to "T7"

DEAL&PAUSE Face Up to "T4"
DEAL&PAUSE Face Down to "T5"
DEAL&PAUSE Face Down to "T6"
DEAL&PAUSE Face Down to "T7"

DEAL&PAUSE Face Up to "T5"
DEAL&PAUSE Face Down to "T6"
DEAL&PAUSE Face Down to "T7"

DEAL&PAUSE Face Up to "T6"
DEAL&PAUSE Face Down to "T7"

DEAL&PAUSE Face Up to "T7"

HELP "Tableau"
HELP "Objective"

STARTGAME
